#ifndef _BINARY_SEARCH_MAP_H_
#define _BINARY_SEARCH_MAP_H_

#include "BinarySearchArray.h"

template<typename V, typename K>
struct PairKeyExtrctor;

template<typename K, typename V, typename Pr = less<K> >
class BinarySearchMap: public BinarySearchArray<K, pair<const K, V>, Pr, PairKeyExtrctor<V, K> > {
public:
	typedef K key_type;
	typedef V data_type;
	typedef BinarySearchArray<K, pair<const K, V>, Pr, PairKeyExtrctor<V, K> > BaseClass;
	data_type& operator[](const key_type& theKey) {
		typename BaseClass::iterator it = find(theKey);
		if (it != BaseClass::end()) {
			return it->second;
		}
		data_type dat;
		return BaseClass::insert(make_pair(theKey, dat)).first->second;
	}
};

#endif